import React, {FC, useMemo} from "react";
import FormPage from "./FormPage.tsx";
import ListPage from "./ListPage.tsx";
import "./css/FormListPage.less"

interface FormListPageProps {
    view: string,
    viewName: string
}

const FormListPage: FC<FormListPageProps> = (props) => {
    const renderForm = useMemo(() => {
        if (!props.view) {
            return null
        }
        return (
            <FormPage
                {...props}
                menuId={""}
                menu={null}
            />
        )
    }, []);

    const renderList = useMemo(() => {
        if (!props.viewName) {
            return null
        }
        return (
            <ListPage
                {...props}
            />
        )
    }, [])

    const renderFormListPage = useMemo(() => {
        return (
            <div className="sf_core_form_list_page">
                {renderForm}
                {renderList}
            </div>
        )
    }, [props]);

    return (renderFormListPage);
};

export default React.memo(FormListPage);